// index.js
// 获取应用实例

import { Banner,category,goodsList } from "../../utils/http";


Page({
  data: {
    startSwiper:[],
    categoryList:[],
    livelistimg:[],
    GoodsLists:[]
  },
  godetails(e){
    console.log(e);
    let id = e.currentTarget.dataset.id;
    console.log(id);
    wx.navigateTo({
      url: '/pages/details/details?id='+id,
    })
  },
  onLoad: function (options) {
    let { startSwiper,categoryList,livelistimg,GoodsLists } = this.data;
    Banner().then((res) =>{
      console.log(res)
      if (res.msg == "success") {
        res.data.map((v) =>{
          if (v.type =="index") {
            startSwiper.push(v) 
          }
          if (v.type =="livelist") {
            livelistimg.push(v) 
          }
        })
      }
      this.setData({
        startSwiper,
        livelistimg
      })
    })
    category().then(ress=>{
      console.log(ress);
      categoryList=ress.data
      this.setData({
        categoryList
      })
    })
    goodsList().then(res=>{
      console.log('123',res);
      GoodsLists=res.data.result
      console.log(GoodsLists);
      this.setData({
        GoodsLists
      })
    })
   
  }
})
